<template>
	<el-table v-bind="$attrs" border highlight-current-row style="margin-left: 45px">
		<el-table-column align="center" width="140" prop="id" label="ID" />
		<el-table-column align="center" width="140" prop="billCode" label="盘点单号" />
		<el-table-column align="center" width="220" prop="warehouseName" :label="$t('checkStock.warehouse')">
			<template #default="scope">
				<span class="label label-primary border-radius-left25">{{ scope.row.mesWarehouseName || '-' }}</span
				><span class="label label-light border-radius-right25">{{ scope.row.mesWarehouseCode || '-' }}</span>
			</template>
		</el-table-column>
		<el-table-column prop="status" width="120" :label="$t('checkStock.status') " align="center" >
			<template #default="scope">
				<el-tag :type="getTagAttrByStatus(scope.row.status).type" :plain="getTagAttrByStatus(scope.row.status).plain">
					{{ getCheckStatusItemText(scope.row.status) }}
				</el-tag>
			</template>
		</el-table-column>
		<el-table-column align="center" width="120" prop="auditedUserName" label="审核人员" />
		<el-table-column align="center" width="120" prop="auditedSign" label="签名">
			<template #default="scope">
				<el-button type="primary" plain icon="view" v-if="scope.row.auditedSign" @click="show(scope.row.auditedSign)">
					查看
				</el-button>
			</template>
		</el-table-column>
		<el-table-column align="center" width="180" prop="auditedTime" label="审核日期" />
		<el-table-column width="120" label="操作" prop="options" align="center">
			<template #default="scope">
				<el-button type="warning" onclick="" v-if="scope.row.status && scope.row.status == 'Audited'" @click="returnAuditMethod(scope.row)"
					><i class="fa fa-undo"></i> 反审
				</el-button>
			</template>
		</el-table-column>
	</el-table>

</template>
<script setup lang="ts">
import { checkStockReturnAudit } from '/@/api/platform/mes/wmsCheckstock';
import { useMessage } from '/@/hooks/message';
import { getCheckStatusItemText, getTagAttrByStatus } from '/@/views/wms/checkStock/data';

const emit = defineEmits(['changeStatus','showImage']);
const show = (img) => {
	emit('showImage', img);
}
function returnAuditMethod(row) {
	const id = row.id;
	checkStockReturnAudit([id]).then((res) => {
		if (res?.code == 0) {
			emit('changeStatus', row.billCode);
			useMessage().success('反审成功');
		} else {
			useMessage().error(res?.msg || '反审失败');
		}
	});
}
</script>
<style scoped lang="scss">
.label {
	display: inline-block;
	padding: 0.2em 0.6em 0.3em;
	font-size: 75%;
	font-weight: 700;
	line-height: 20px;
	min-width: 60px;
	color: #fff;
	text-align: center;
	white-space: nowrap;
	vertical-align: baseline;
	/*border-radius-: .25em;*/
}

.label-success {
	background-color: #5cb85c;
}

.label-default {
	background-color: #777;
}

.label-primary {
	background-color: #337ab7;
}

.label-secondary {
	background-color: #6c757d;
}

.label-light {
	color: #212529;
	background-color: #f8f9fa;
}

.border-radius-left25 {
	border-radius: 0.25em 0 0 0.25em;
}

.border-radius-right25 {
	border-radius: 0 0.25em 0.25em 0;
}
.demo-image__error .image-slot {
	font-size: 30px;
}

.demo-image__error .image-slot .el-icon {
	font-size: 30px;
}

.demo-image__error .el-image {
	width: 100%;
	height: 200px;
}

::v-deep(.el-table__cell) {
	position: static !important;
}

::v-deep(.el-image-viewer__mask) {
	opacity: .7 !important;
}
</style>
